﻿using System;
using System.Collections.Generic;
using System.Text;
using RobotRace.engine.robossConnector;
using FIRADriverLibrary;
using System.Threading;
using RoBOSSCommunicator;
using PotentialFieldDriver.robotrace.environment.implementation;
using PotentialFieldDriver.robotrace.environment.interfaces;

namespace RobotRace.engine
{
    class Example
    {
        unsafe static void Main(string[] args)
        {
            string ip = "192.168.1.100";
            string port = "4468";

            RobossConnector connector = RobossConnector.getConnector(ip, port);
            PitchInterface pitch = new Pitch(connector.getWorldDefinition(), connector.getRobots());

            FIRARobotState robot = connector.getRobots()[0];
            Console.WriteLine("Number of robots is: " + connector.getRobots().Length);
            FIRADriver driver = connector.getFiraDriver();
            //connector.requestRobot(robot);
            if (driver.RequestRobot(robot.portId) < 0)
            {
                Console.WriteLine("Unable to request robot: " + FIRADriver.lastError);
                return;
            }
            while(true)
            {
                driver.Step();
                robot.leftSpeed = 1.0;
                robot.rightSpeed = 1.0;
                Console.WriteLine(robot.x + ", " + robot.y);
                Console.WriteLine("Owned: " + robot.owned);
                Thread.Sleep(1);
            }
        }
    }
}
